******************************************
*
*	Article: The Human Costs of the War on Drugs: Attitudes towards Militarization of Security in Mexico
*	Authors: Juan Masullo J., Davide Morisi
*	Journal: Comparative Political Studies
*	Date: 23 March 2023
*
*	This file replicates the following
*	APPENDIX E - LAPOP DATA
*
*	All analyses performed with Stata/SE 14.2 for Windows
******************************************

*Data source: Latin American Public Opinion Project (LAPOP), https://www.vanderbilt.edu/lapop/
*Data downloaded on 13 December 2019

*Set working directory
*[my working directory]

*Combined dataset merging the following files and keeping only variables needed for the analysis
*2004-2018 LAPOP AmericasBarometer Merge (v1.0FREE).dta
*244461055Ecuador LAPOP AmericasBarometer 2014 v3.0_W.dta
*1140434363Bolivia LAPOP AmericasBarometer 2014 v3.0_W.dta
*553131127Chile LAPOP AmericasBarometer 2014 v3.0_W.dta
*822140976Venezuela LAPOP AmericasBarometer 2014 v3.0_W.dta
*1757856948Argentina LAPOP AmericasBarometer 2014 v3.0_W.dta

*Open dataset
use "Replication_CPS\Data\lapop_2014_merged.dta", clear


****
*Figure E1. Support for militarization of security in Latin America (2014)

gen army01 = (mil7-1)/6 if mil7<=7
egen marmy = mean(army01), by(pais)
recode pais (25 26 28 29=.), gen(pais_rec)
label val pais_rec pais_eng
graph hbar marmy if army01!=., over(pais_rec, sort(marmy) descending) ///
	blabel(bar, position(inside) format(%9.2f) color(white)) graphregion(color(white))

	
****
*Figure E2. Trust in the army in Latin America (2014)

gen trust01 = (b12-1)/6 if b12<=7
egen mtrust = mean(trust01), by(pais_rec)
ta pais_rec if mtrust!=.
graph hbar mtrust if mtrust!=., over(pais_rec, sort(mtrust) descending) ///
	blabel(bar, position(inside) format(%9.2f) color(white)) graphregion(color(white))


********************
*Data about Mexico only (2004-2018)

/*Combined dataset merging the following files and keeping only variables needed for the analysis
Mexico LAPOP AmericasBarometer 2019 v1.0_W.dta
275973272Mexico LAPOP AmericasBarometer 2017 V1.0_W.dta
534049480Mexico LAPOP AmericasBarometer 2014 v3.0_W.dta
641926122Mexico LAPOP AmericasBarometer 2012 Rev1_W.dta
2054050000Mexico_LAPOP_AmericasBarometer 2010 data set  approved V5.dta
886309252Mexico_2008_LAPOP_DIMS final data set v10.dta
518939279mexico_lapop_final 2006 data set 092906.dta
642348348mexico 2004 export version.dta
*/

*Open dataset 
use "Replication_CPS\Data\lapop_mexico_merged.dta", clear

***
*Recode trust variables

*trust in the army
gen trust_army01 = (b12-1)/6 if b12<8
*trust in national congress
gen trust_congr01 = (b13-1)/6 if b13<8
*trust in government/president
gen trust_gov = b14 if year<2008
replace trust_gov = b21a if year>2006
gen trust_gov01 = (trust_gov-1)/6 if trust_gov<8
*trust in political parties
gen trust_party01 = (b21-1)/6 if b21<8


***
*Figure E3. Changing levels of trust in Mexico (2004-2018)
egen mtrust_army = mean(trust_army01), by(year)
egen mtrust_congr = mean(trust_congr01), by(year)
egen mtrust_gov = mean(trust_gov01), by(year)
egen mtrust_party = mean(trust_party01), by(year)

twoway (scatter mtrust_army year, sort(year) connect(ascending) color(blue) xlabel(2004(2)2018, valuelabel) title("Trust trend Mexico") ///
	ytitle("Average trust from 0 to 1")) ///
	(scatter mtrust_congr year, sort(year) connect(ascending) color(red)) ///
	(scatter mtrust_gov year, sort(year) connect(ascending) color(green)) ///
	(scatter mtrust_party year, sort(year) connect(ascending) color(orange)) 


***
*Figure E4. Support for a military coup in the presence of high crime

recode jc10 1=1 2=0 else=., gen(coup)
graph bar coup, over(year) ytitle("Military coup justified (%)") graphregion(color(white)) ///
blabel(bar, position(inside) format(%9.2f) color(white))



